import cv2
import numpy as np
 
def subimage(image, center, theta, width, height):
    theta *= np.pi / 180 # convert to rad
    v_x = (np.cos(theta), np.sin(theta))
    v_y = (-np.sin(theta), np.cos(theta))
    s_x = center[0] - v_x[0] * (width / 2) - v_y[0] * (height / 2)
    s_y = center[1] - v_x[1] * (width / 2) - v_y[1] * (height / 2)
    mapping = np.array([[v_x[0],v_y[0], s_x],
                        [v_x[1],v_y[1], s_y]])
    return cv2.warpAffine(image,mapping,(width, height),flags=cv2.WARP_INVERSE_MAP,borderMode=cv2.BORDER_REPLICATE)
 
image = cv2.imread('E:\\sda\\alin\\11A69.jpg')  
#image = subimage(image, center=(396, 1368), theta=0, width=546, height=1890)
image = subimage(image, center=(1080, 1491), theta=0, width=1368, height=1890)
#cv2.imwrite('patch.jpg', image)
cv2.imshow('patch.jpg',image)
cv2.imwrite('patch.jpg', image)
cv2.waitKey(0)
cv2.destroyAllWindows()